package main

import (
	"fmt"
	"strings"
	"unicode/utf8"
)

func main() {
	s := "Yes我爱慕课网!" //UTF-8 中文三字节
	for _, v := range []byte(s) {
		fmt.Printf("%X ", v)
	}
	fmt.Println("字符串的长度", len(s))

	for i, ch := range s { //ch is a rune
		fmt.Printf("(%d %X) ", i, ch)
	}
	fmt.Println()
	fmt.Println("字符串的长度", utf8.RuneCountInString(s))

	bytes := []byte(s)
	for len(bytes) > 0 {
		ch, size := utf8.DecodeRune(bytes)
		bytes = bytes[size:]
		fmt.Printf("%d => %c \n", ch, ch)
	}
	fmt.Println("======= strings包下的常用操作 Fields Split Join =======")
	fields := strings.Fields("我是王小丫 你是刘明利 你好world")
	fmt.Println(fields, len(fields))
	fmt.Println("======= strings包下的常用操作 Contains Index =======")

	fmt.Println("======= strings包下的常用操作 ToLower ToUpper =======")

	fmt.Println("======= strings包下的常用操作 Trim TrimRight TrimLeft =======")

}
